import request from '@/utils/request'

export const userRegisterService = (registerData) => {
    const params = new URLSearchParams()
    for (let key in registerData) {
        params.append(key, registerData[key])
    }
    // console.log(registerData)
    // console.log(params)

    return request.post('/user/register', params)
}

export const userLoginService = (loginData) => {
    const params = new URLSearchParams()
    for (let key in loginData) {
        params.append(key, loginData[key])
    }
    // console.log(registerData)
    return request.post('/user/login', params)
}

export const userInfoService = () => {
    return request.get('/user/userInfo')
}

export const updateUserInfoService = (userInfoData) => {
    return request.put('/user/update', userInfoData)
}

export const updateUserAvatarService = (avatarUrl) => {
    const params = new URLSearchParams()
    params.append('avatarUrl', avatarUrl)
    return request.patch('/user/updateAvatar', params)
}

export const repasswordService = (registerData) => {
    let params={
        'old_pwd':registerData.value.oldpassword,
        'new_pwd':registerData.value.password,
        're_pwd':registerData.value.repassword
    }
    return request.patch('/user/updatePwd', params)
}